home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
simula
/
books
/
books.lha
/
kirkerud
/
fibo2.sim
< prev
next >
Wrap
Text File
|
1993-08-16
|
613b
|
30 lines
begin
! Proposed solution to exercise 3.8 (second program);
integer n, possible_fib, prev_fib, fib_i, next_fib;
outtext("Type an integer> "); breakoutimage;
inimage; possible_fib := inint;
prev_fib := 1; fib_i := 1;
n := 2;
while fib_i < possible_fib do
begin
next_fib := prev_fib + fib_i;
prev_fib := fib_i;
fib_i := next_fib;
n := n + 1;
end;
outint(possible_fib, 0);
if fib_i = possible_fib then
begin
outtext(" is Fibonacci number ");
outint(n, 0);
end
else outtext(" is not in the Fibonacci sequence");
outimage;
end